<#
 #   It is recommended to test the script on a local machine for its purpose and effects. 
 #   ManageEngine Endpoint Central will not be responsible for any 
 #   damage/loss to the data/setup based on the behavior of the script.

 #   Description: Script is designed To Check LAPS status
 #   Configuration Type - COMPUTER
 #   Refer: https://learn.microsoft.com/en-us/windows-server/identity/laps/laps-management-policy-settings
 #>

# Define the registry keys to check

# LAPS CSP, LAPS Group Policy, LAPS Local Configuration, Legacy Microsoft LAPS

$registryKeys = @(
    "HKLM:\Software\Microsoft\Policies\LAPS",
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\LAPS",  
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\LAPS\Config",
    "HKLM:\Software\Policies\Microsoft Services\AdmPwd"
)

# Initialize a flag to check activation status
$activated = $false

# Loop through each registry key to check if it exists
foreach ($key in $registryKeys) {
    if (Test-Path $key) {
        Write-Output "Registry key exists: $key"
        $activated = $true
    }
}

# Output activation status
if ($activated) {
    Write-Output "Activated"
} else {
    Write-Output "Not Activated"
}